home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / misc / math / EqEd.lha / EqEd / rexx / InsertFw.eqed < prev   
Encoding:
Text File  |  1995-05-18  |  2.2 KB  |  103 lines

  1. /* insertfw.eqed -- Insert equation into FinalWriter
  2.  *
  3.  * This script will insert the current equation into FinalWriter
  4.  * It is based on a script made by David Shaffer.
  5.  * It will save the current equation in Encapsulated PostScript
  6.  * with an embedded equation, and insert it in FinalWriter.
  7.  * If the current object has the same name, it will replaced by
  8.  * the new one. See the manual for more details.
  9.  *
  10.  * It requires rexxreqtools.library
  11.  */
  12.  
  13. options results
  14.  
  15. IF ~SHOW('p',"FINALW.1") THEN EXIT 
  16.  
  17. if ~show('l','rexxreqtools.library') then
  18.    if ~addlib('rexxreqtools.library',0,-30,0) then EXIT
  19.  
  20. /* Save old settings */
  21. GetOutput
  22. OldOutput=result
  23.  
  24. GetName
  25. Name=result
  26. if Name = '' then do
  27.     /* Get default directory name from FW*/
  28.     address 'FINALW.1' status pathname
  29.     defpath = result
  30.     DivPos = max(lastpos(':',defpath),lastpos('/',defpath))+1
  31.     defpath = left(defpath,DivPos-1)
  32.     Name = rtfilerequest(defpath,,'Enter file name','Accept',,)
  33.     if Name = '' then EXIT
  34. end
  35.  
  36. /* Save equation and get boundingbox information! */
  37. SETOUTPUT PREVIEWPS EMBEDDED
  38. Save Name
  39. bb = result
  40.  
  41. /* Restore old settings */
  42. SetOutput SUBWORD(OldOutput,1,1) SUBWORD(OldOutput,2,1)
  43.  
  44. /* Now on to final writer */
  45. ADDRESS "FINALW.1"
  46.  
  47. status page "Insert"
  48. page = result
  49. setmeasure micropoints
  50.  
  51. /* Now get info about the currently selected object */
  52. currentobject
  53. co = result
  54. ot = ''
  55. xoffset = 0
  56. yoffset = 0
  57. if co ~= 0 then
  58.   do
  59.     getobjecttitle
  60.     ot = result
  61.     if ot = name then
  62.       do
  63.         getobjectparams co textflow flowdist linked display
  64.         objparams = result
  65.         getobjectcoords co
  66.         objcoords = result
  67.         page = word(objcoords,1)
  68.         xoffset = word(objcoords,2)
  69.         yoffset = word(objcoords,3)
  70.         deleteobject co
  71.       end
  72.   end
  73.  
  74. /* -- convert to micropoints and strip off decimals */
  75. bbmp = ''
  76. do i = 1 to 4
  77.   val = word(bb,i)
  78.   if lastpos('.',val) ~= 0 then val = left(val,lastpos('.',val)-1)
  79.   val = val * 10
  80.   if i = 1 then val = val + xoffset
  81.   if i = 2 then val = val + yoffset
  82.   bbmp = bbmp || ' ' || val
  83. end
  84.  
  85. /* Insert the image. */
  86.  
  87. IMPORTPREFS DISPLAY PREVIEW TEXTFLOW NONE LINKED NO
  88.  
  89. INSERTIMAGE name POSITION page bbmp
  90. currentobject
  91. co = result
  92.  
  93. if name ~= '' then
  94.   do
  95.     setobjecttitle co name
  96.   end
  97.  
  98. SCREENTOFRONT
  99.  
  100. REDRAW
  101.  
  102.  
  103.